<template>
  <div class="menu-item">
    <div v-for="item in menuData" :key="item.index">
      <el-submenu v-if="item.children&&item.children.length>0" :index="item.index">
        <template slot="title">
          <i :class="item.img"></i>
          <span slot="title">{{ item.name }}</span>
        </template>
        <menu-item :menuData="item.children"></menu-item>
      </el-submenu>
      <el-menu-item v-else :index="item.path" @click="goRouter(item)">
        <i :class="item.img"></i>
        <span slot="title">{{ item.name }}</span>
      </el-menu-item>
    </div>
  </div>
</template>

<script type="text/javascript">
export default {
  name: 'menuItem',
  props: ['menuData'],
  data () {
    return {}
  },
  components: {},
  methods: {
    goRouter (value) {
      this.$router.push({ path: value.path })
    }
  }
}
</script>

<style lang="scss" scoped>
.menu-item {
  .el-menu-item,
  ::v-deep .el-submenu__title {
    height: 40px;
    line-height: 40px;
  }
}

</style>
